package Interface.Producao.Descontos;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LerDescontos {
    
    private static LerDescontos instance = null;
    
    public LerDescontos() {
    }

    public static LerDescontos getInstance() {
        if(instance == null){
            instance = new LerDescontos();
        }
        return instance;
    }
    
    private List<String[]> list = new ArrayList<>();
    private String[] split = null;
    
    public List<String[]> lerArquivo(String filename){
        try {
            FileReader file = new FileReader(filename);
            BufferedReader buff = new BufferedReader(file);
            String readLine = buff.readLine();

            while (readLine != null) {
                split = readLine.split(";");
                
                if(split[7] != null){
                    String[] split1 = split[7].split("\\*");
                    split[7] = split1[0];
                }
                    list.add(split);
                
                readLine = buff.readLine();
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
        }
        return list;
    }
    
}
